package com.hitfm.iplay.util;

import java.sql.Date;
import java.text.DateFormat;

import android.content.Context;

public class ConvertNum {
	public static String milliToSecs(long milliSecs) {
		if (milliSecs <= 0) {
			return "00:00";
		}
		StringBuffer sb = new StringBuffer();
		long m = milliSecs / (60 * 1000);
		sb.append(m < 10 ? "0" + m : m);
		sb.append(":");
		long s = (milliSecs % (60 * 1000)) / 1000;
		sb.append(s < 10 ? "0" + s : s);
		return sb.toString();
	}

	public static String longToSize(long size) {
		if (size <= 0) {
			return "0 KB";
		}
		size=size/(1000*1000/10);
		StringBuffer sb = new StringBuffer();
		long mb = size / 10;
			sb.append(mb + ".");
		long kb = size  % 10;
		sb.append(kb + "MB");
		return sb.toString();
	}

	public static String formatDateString(Context context, long time) {
		DateFormat dateFormat = android.text.format.DateFormat.getDateFormat(context);
		DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(context);
		Date date = new Date(time);
		return dateFormat.format(date) + " " + timeFormat.format(date);
	}
}
